//
//  Enums.swift
//  clreader
//
//  Created by colin on 2019/3/6.
//  Copyright © 2019 colin. All rights reserved.
//

import Foundation

enum SourceType {
    case 图文
    case 音频
    case 视频
    case 电子书
    case 精讲
    case 专题
    case 有声书
    
    init?(type:Int?) {
        guard let type_ = type else {
            return nil
        }
        
        switch type_ {
        case 1: self = .图文
        case 2: self = .音频
        case 3: self = .视频
        case 4: self = .电子书
        case 5: self = .精讲
        case 6: self = .专题
        case 7: self = .有声书
        default: return nil
        }
    }
    
    var name:String {
        switch self {
        case .图文: return "图文"
        case .音频: return "音频"
        case .视频: return "视频"
        case .电子书: return "电子书"
        case .精讲: return "精讲"
        case .专题: return "专题"
        case .有声书: return "有声书"
        }
    }
    
    var tagName:String {
        switch self {
        case .图文: return "source_tag_1"
        case .音频: return "source_tag_2"
        case .视频: return "source_tag_3"
        case .电子书: return "source_tag_4"
        case .精讲: return "source_tag_5"
        case .专题: return "source_tag_6"
        case .有声书: return "source_tag_7"
        }
    }
    
    var intValue:Int {
        switch self {
        case .图文: return 1
        case .音频: return 2
        case .视频: return 3
        case .电子书: return 4
        case .精讲: return 5
        case .专题: return 6
        case .有声书: return 7
        }
    }
    
}
